

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layuiAdmin 添加管理员 iframe 框</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/admin/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/admin/layuiadmin/style/admin.css" media="all">
</head>
<body style="padding-top:30px;">
      <div class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">账号</label>
            <div class="layui-input-block">
              <input type="text" name="username" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required" value="">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
              <input type="password" name="password" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required" value="">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
              <input type="text" name="name" placeholder="请输入" id="name" autocomplete="off" class="layui-input" lay-verify="required" value="">
            </div>
          </div>
            <div class="layui-inline">
              <label class="layui-form-label">角色</label>
              <div class="layui-input-block">
                <select name="role_id" lay-verify="required">
                  {volist name="roles" id='role'}
                  <option value="{$role.id}">{$role.name}</option>
                  {/volist}
                </select>
              </div>
            </div>


        </div>
           <div class="layui-form-item layui-hide">
      <button class="layui-btn" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-front-submit">提交</button>
    </div>
      </div>
  <script src="/admin/layuiadmin/layui/layui.js"></script>
  <script>
      layui.config({
          base: '/admin/layuiadmin/' //静态资源所在路径
      }).extend({
          index: 'lib/index' //主入口模块
      }).use(['index', 'form'], function(){
          var $ = layui.$
              ,form = layui.form ;

          var active = {
              chaxun:function(){
                  layer.open({
                      type: 2
                      ,title: '搜索用户'
                      ,content: '/admin/Organization/sousuo'
                      ,maxmin: true
                      ,area: ['500px', '450px']
                      ,btn: ['确定', '取消']
                      ,success: function(layero,index){
                          var body = layui.layer.getChildFrame('body', index);
                          body.find("#id").val(id);
                          body.find("#title").val(title);
                          form.render();
                      }
                      ,yes: function(index, layero){
                          var iframeWindow = window['layui-layer-iframe'+ index]
                              ,submitID = 'LAY-user-front-submit'
                              ,submit = layero.find('iframe').contents().find('#'+ submitID);
                          //监听提交
                          iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
                              var field = data.field; //获取提交的字段
                              var uid=field.uid;
                              $('#uid').val(uid);
                              layer.close(index); //关闭弹层
                          });
                          submit.trigger('click');
                      }
                  });
              }
          }
          $('.chaxun').on('click', function(){
              var type = $(this).data('type');
              active[type] ? active[type].call(this) : '';
          });


      })
  </script>
</body>
</html>